<!DOCTYPE html>
<html lang="en">

<head>
 <meta charset="UTF-8">
 <meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <title>逛水果店</title>
 <style>
   #app {
    width: 1200px;
    margin: 0px auto;
   }

   table,
   tr,
   td {
    border: 2px solid #2f69d5;
   }

   td {
    width: 1000px;
    height: 50px;
    text-align: center;
   }
 </style>
</head>

<body>
 <div id="app">
   <table>
    <tr>
      <td>欢迎光临水果店</td>
    </tr>
    <tr>
      <td v-model="n1">苹果{{n1}}元/斤,折扣<8折>
      </td>
    </tr>
    <tr>
      <td>
       输入购买的斤数
       <input type="number" v-model="n2">
      </td>
    </tr>
    <tr>
      <td><button @click="add">结账买单</button></td>
    </tr>
    <tr>
      <td>结账单总价：{{fn}}￥元 折后价{{zhe}} ￥元 省了{{sn}} ￥元</td>
    </tr>
   </table>
 </div>
 <script src="./lib/vue.js"></script>
 <script>
   new Vue({
    el: '#app',
    data: {
      n1: 10,
      n2: 1,
      fn:'',
      zhe: '',
      sn:''
    },
    methods: {
      add() {
       this.fn = this.n1 * this.n2
       this.zhe = this.n1 * this.n2 * 0.8
       this.sn = this.n1 * this.n2 - this.n1 * this.n2 * 0.8
      }
    }
   })
 </script>
</body>

</html>